package cn.edu.thu.thss.creating;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;


public class CreateKsAndCf {

	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		File file=new File("Z:\\data");
		File[] files=file.listFiles();
		for (int i = 0; i < files.length; i++) {
			String string=files[i].getName();
			System.out.println(string);
		}
		Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver");
		Connection con = DriverManager.getConnection("jdbc:cassandra://192.168.3.17:9170?version=2");
		
		Statement laudStatement=con.createStatement();
		laudStatement.execute("use model;");
		for (int i = 0; i < files.length; i++) {
			String string=files[i].getName();
			System.out.println(string);
			laudStatement.execute("CREATE COLUMNFAMILY "+string+"_interval (aspect text PRIMARY KEY) WITH comparator=text AND default_validation=blob;");
			laudStatement.execute("CREATE COLUMNFAMILY "+string+"_level (aspect text PRIMARY KEY) WITH comparator=text AND default_validation=blob;");
		}

	}

}
